# _*_ coding: utf-8 _*_
from operator import itemgetter
def my_abs(x):
    if x > 0:
        return x
    else:
        return -x


# n = 100
# while n > 0:
#     a = int(input())
#     print("abs(%d) = %d" % (a, abs(a)))

# mainList = []
# n = 3
# for i in range(n):
#     a = input()
#     mainList.append(a)
#
# print(mainList)
# print(mainList[0:3])


def by_name(t):
    pass


L = [('Jack', 1000), ('rose', 999), ('jacklove', 1500)]
L2 = sorted(L, key=itemgetter(0), reverse=True)
L3 = sorted(L, key=itemgetter(1) )
print(L2)
print(L3)
